package db_test;

import org.junit.jupiter.api.Test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 * Author: hu
 * Date: 2022/9/9 10:06
 */
public class HiveTest {

        public static void main(String[] args) throws Exception {
                Connection conn=null;
                Statement stat=null;
                ResultSet rs=null;
                Class.forName("org.apache.hive.jdbc.HiveDriver");
                conn = DriverManager.getConnection("jdbc:hive2://192.168.2.167:10000/default","","");
                 stat = conn.createStatement();
//                 stat.execute("create table student (id int , name string)");
                 stat.execute("insert into student values (4,'hello')");
                 rs = stat.executeQuery("select * from student limit 10");
                while (rs.next()) {
                    int id = rs.getInt(1);
                    String name = rs.getString(2);
                    System.out.println(id + ","+name);
                }
                        rs.close();
                        stat.close();
                        conn.close();

    }

    @Test
    public void t(){
            double a =10;
            int b=3;
        System.out.println(a/b);
    }

}
